import React, { useEffect, useState } from "react"
import { jdQuestionnaire } from '@/services/user';


export default () => {
	const [token, setToken] = useState('');

	const customParams = {
		nps: {
			npsNodeIdLv1: 'CJ_LISTEN_JM_ISV', // 传入一级场景id
			npsNodeIdLv2: 'CJ_LISTEN_JM_ISV_ZJF', // 传入自己应用的二级场景id
			token: token, // 传入token证明是isv商家
			npsStatus: true,
		}
	}

	useEffect(() => {
		queryToken();
	}, [])

	//查询token
	const queryToken = async () => {
		const { success, data } = await jdQuestionnaire();
		if (success) {
			setToken(data);
		}
	}

	if (!token) {
		return null;
	}

	return (
		<h1>
			<shop-common-components
				type="NPS"
				custom-params={JSON.stringify(customParams)}
			/>
		</h1>
	)

}